]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionPrefs: Load D-Bus interface from own resource
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 7 Mar 2020 18:26:06 +0000 (19:26 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Thu, 19 Mar 2020 14:27:36 +0000 (14:27 +0000)
Using the "regular" loadInterfaceXML() helper means less code duplication,
but it also ties us to the resource used by gnome-shell.

In order to untangle the extension app from core gnome-shell, change that
to load the interface from the existing data resource instead. While that
does involve reimplementing loadInterfaceXML(), it's not too bad actually
with the resource-loading code stripped (as the data resource is already
loaded by the package module).

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1081

js/extensionPrefs/data/dbus-interfaces/org.gnome.Shell.Extensions.xml [new symlink]
js/extensionPrefs/data/org.gnome.Extensions.data.gresource.xml
js/extensionPrefs/js/main.js
js/extensionPrefs/js/org.gnome.Extensions.src.gresource.xml

diff --git a/js/extensionPrefs/data/dbus-interfaces/org.gnome.Shell.Extensions.xml b/js/extensionPrefs/data/dbus-interfaces/org.gnome.Shell.Extensions.xml
new file mode 120000 (symlink)
index 0000000..defde79
--- /dev/null
@@ -0,0 +1 @@
+../../../../data/dbus-interfaces/org.gnome.Shell.Extensions.xml
\ No newline at end of file
index f6fc66b7219a7606cd3e538ca6dbb01262db0c99..659c03ffc860a68157a75e82b5382d56a3e91934 100644 (file)
@@ -3,6 +3,8 @@
   <gresource prefix="/org/gnome/Extensions">
     <file>css/application.css</file>
 
+    <file>dbus-interfaces/org.gnome.Shell.Extensions.xml</file>
+
     <file>ui/extension-row.ui</file>
     <file>ui/extensions-window.ui</file>
   </gresource>
index 936598c0542b29fae393473cba1ec911bcac123d..e4e2328c613c229465641ed44db29109c4597947 100644 (file)
@@ -10,13 +10,26 @@ const { Gdk, GLib, Gio, GObject, Gtk } = imports.gi;
 const _ = Gettext.gettext;
 
 const ExtensionUtils = imports.misc.extensionUtils;
-const { loadInterfaceXML } = imports.misc.fileUtils;
 
 const { ExtensionState, ExtensionType } = ExtensionUtils;
 
 const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
 const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
 
+function loadInterfaceXML(iface) {
+    const uri = 'resource:///org/gnome/Extensions/dbus-interfaces/%s.xml'.format(iface);
+    const f = Gio.File.new_for_uri(uri);
+
+    try {
+        let [ok_, bytes] = f.load_contents(null);
+        return imports.byteArray.toString(bytes);
+    } catch (e) {
+        log('Failed to load D-Bus interface %s'.format(iface));
+    }
+
+    return null;
+}
+
 function stripPrefix(string, prefix) {
     if (string.slice(0, prefix.length) == prefix)
         return string.slice(prefix.length);
index 9b0fa09acea980690fdf29d9a9853c3b9cb1ddca..8cda0f91ad92fc1f1053307fb9b29ca00ea38ce3 100644 (file)
@@ -5,6 +5,5 @@
 
     <file>misc/config.js</file>
     <file>misc/extensionUtils.js</file>
-    <file>misc/fileUtils.js</file>
   </gresource>
 </gresources>